package fr.umlv.galcon.ship;

import fr.umlv.galcon.ship.type.MediumShip;
import fr.umlv.galcon.ship.type.StrongShip;
import fr.umlv.galcon.ship.type.WeakShip;

public enum ShipProperties {
    NEUTRAL(0, 0, 0) {
	@Override
	public ShipAbstract createShip(int x, int y, int width, Squadron squadron) {
	    return null;
	}
    },
    WEAK(10, 1, 1) {
	@Override
	public ShipAbstract createShip(int x, int y, int width, Squadron squadron) {
	    return new WeakShip(x, y, width, squadron);
	}
    },
    MEDIUM(8, 2, 2) {
	@Override
	public ShipAbstract createShip(int x, int y, int width, Squadron squadron) {
	    return new MediumShip(x, y, width, squadron);
	}
    },
    STRONG(6, 3, 3) {
	@Override
	public ShipAbstract createShip(int x, int y, int width, Squadron squadron) {
	    return new StrongShip(x, y, width, squadron);
	}
    };

    private int speed;
    private int power;
    private int production;

    private ShipProperties(int speed, int power, int production) {
	this.speed = speed;
	this.power = power;
	this.production = production;
    }

    /**
     * Create a ship.
     * 
     * @param x
     *            X coordinate of the Ship.
     * @param y
     *            Y coordinate of the Ship.
     * @param width
     *            Width of the Ship.
     * @param squadron
     *            Squadron which in is the Ship.
     * @return The created Ship.
     */
    public abstract ShipAbstract createShip(int x, int y, int width, Squadron squadron);

    public int getSpeed() {
	return speed;
    }

    public int getPower() {
	return power;
    }

    public int getProduction() {
	return production;
    }

    public static ShipProperties getShipById(int id) {
	switch (id) {
	case 0:
	    return WEAK;
	case 1:
	    return STRONG;
	case 2:
	    return MEDIUM;

	default:
	    return NEUTRAL;
	}
    }

}
